(function( $ ) {
 
    $.fn.accordion = function(options) {
        var settings = $.extend({
            collapse	: false,
			after 		: function(){}
        }, options );
        
        return this.each(function() {
            var el = $(this);
			el.find('.accordionController').each(function() {
				var fireEl = $(this);
				if (fireEl.siblings('.fire').length > 0) {
					fireEl.siblings('.fire').each(function() {
						$(this).height($(this).parent().height());
					});
					fireEl = fireEl.siblings('.fire');
				}
				fireEl.click(function(){
					if (settings.collapse) {
						el.find('.accordionBody').slideUp();
						// remove opening state from other ul
						fireEl.parent().siblings('.accordionBody').removeClass('opened');
					}
					else {
						$(this).siblings('.accordionBody').slideUp(settings.after);
						fireEl.removeClass('down');
					}
					if(!$(this).siblings('.accordionBody').is(":visible"))
					{
						fireEl.addClass('down');
						$(this).siblings('.accordionBody').slideDown(settings.after);
						fireEl.parent().addClass('opened');
					} else {
						fireEl.parent().removeClass('opened');
					}
				})
			});
            
        });
    };
 
}( jQuery ));